#include "stdio.h"

int main(){
	int max_school,school,max=0,i,n,a[1000001]={0},score;
		scanf("%d",&n);
	for(i=0;i<n;i++){
	 scanf("%d %d",&school,&score);
		a[school]+=score;
		if(a[school]>max){
			max=a[school];
			max_school=school;
		}
	}
	    printf("%d %d",max_school,max);
	return 0;
}
